package com.xc.hotelmgr.webapi.modules.op.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xc.hotelmgr.webapi.common.utils.PageUtils;
import com.xc.hotelmgr.webapi.common.utils.Query;

import com.xc.hotelmgr.webapi.modules.op.dao.HtlPriceDao;
import com.xc.hotelmgr.webapi.modules.op.entity.HtlPriceEntity;
import com.xc.hotelmgr.webapi.modules.op.service.HtlPriceService;


@Service("htlPriceService")
public class HtlPriceServiceImpl extends ServiceImpl<HtlPriceDao, HtlPriceEntity> implements HtlPriceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String dtId = (String)params.get("dtId");
        String hotelId = (String)params.get("hotelId");
        String storeId = (String)params.get("storeId");
        IPage<HtlPriceEntity> page = this.page(
                new Query<HtlPriceEntity>().getPage(params),
                new QueryWrapper<HtlPriceEntity>().eq(StringUtils.isNotBlank(dtId),"dt_id",dtId)
                        .eq(StringUtils.isNotBlank(hotelId),"hotel_id",hotelId)
                        .eq(StringUtils.isNotBlank(storeId),"store_id",storeId)
        );

        return new PageUtils(page);
    }

    @Override
    public List<HtlPriceEntity> getListByHotelId(Long hotelId) {
        return baseMapper.getListByHotelId(hotelId);
    }

}